package work20241207_chap8.l;



/**
 * @author zdl
 * @date 2024/12/3
 */
public class Soldier extends NameRole implements Role {
    private int hurt;
    private Weapon weapon;

    public Weapon getWeapon() {
        return weapon;
    }

    public Soldier(String name, int age, int hurt, Weapon weapon) {
        super(name, age);
        this.hurt = hurt;
        this.weapon = weapon;
    }

    public Soldier(int hurt, Weapon weapon) {
        this.hurt = hurt;
        this.weapon = weapon;
    }

    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }

    public Soldier(){}

    public Soldier(int hurt) {
        this.hurt = hurt;
    }



    public int getHurt() {
        return hurt;
    }

    public void setHurt(int hurt) {
        this.hurt = hurt;
    }

    @Override
    public int attack() {
        return hurt+ weapon.fire();
    }

    @Override
    public void practise() {
        hurt = hurt+10;
    }

    @Override
    public String toString() {
        return "Soldier{" +
                "hurt=" + hurt +
                '}';
    }
}
